package com.automannn.atm_back.modules.codeGenerator.entity;

import com.automannn.atm_back.modules.codeGenerator.core.pojo.ColumnInfo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author chenkh
 * @time 2020/7/10 9:38
 */
@Data
@TableName("generator_column_config")
public class ColumnConfigEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    private String id;

    /**
     * 所属配置组id
     */
    private String columnConfigGroupId;

    /**
     * 原始名称
     */
    private String srcName;

    /**
     * 转换名称
     */
    private String targetName;

    /**
     * 注释
     */
    private String comment;

    /**
     * 全类型
     */
    private String type;
    /**
     * 短类型
     */
    private String shortType;

    /**
     * 标签
     */
    private String labelName;

    /**
     * 表单数据类型
     */
    private String formItemType;

    /**
     * 表单数据源 类型
     */
    private String formItemSourceType;

    /**
     * 表单数据源
     */
    private String formItemSource;

    /**
     * 表单验证规则
     */
    private String formItemRules;

    /**
     * 是否必填
     */
    private String require;

    /**
     * 是否隐藏
     */
    private String hidden;

    /**
     * 模糊匹配
     */
    private String vagueConfigCode;

    /**
     * 扩展字段
     */
    private String ext1;
    private String ext2;
    private String ext3;
    private String ext4;
    private String ext5;
    private String ext6;
    private String ext7;
    private String ext8;
    private String ext9;
    private String ext10;

    private String createUser;
    private Date createTime;
    private String updateUser;
    private Date updateTime;
    private String effective;

    public ColumnInfo toColumnInfo(){
        ColumnInfo columnInfo =new ColumnInfo();
        columnInfo.setSrcName(srcName);
        columnInfo.setTargetName(targetName);
        columnInfo.setComment(comment);
        columnInfo.setLabelName(labelName);
        columnInfo.setType(type);
        columnInfo.setShortType(shortType);
        columnInfo.setCustom(false);
        columnInfo.setFormItemRules(formItemRules);
        columnInfo.setFormItemSource(formItemSource);
        columnInfo.setFormItemSourceType(formItemSourceType);
        columnInfo.setFormItemType(formItemType);
        columnInfo.setRequire(require);
        columnInfo.setHidden(hidden);
        Map map = new HashMap();
        map.put("ext1",ext1);
        map.put("ext2",ext2);
        map.put("ext3",ext3);
        map.put("ext4",ext4);
        map.put("ext5",ext5);
        map.put("ext6",ext6);
        map.put("ext7",ext7);
        map.put("ext8",ext8);
        map.put("ext9",ext9);
        map.put("ext10",ext10);
        columnInfo.setExt(map);
        return columnInfo;
    }

}
